home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / Periodic Tasksƒ / CPPSpawnConfirmTask.cp < prev    next >
Encoding:
Text File  |  1996-04-04  |  2.2 KB  |  83 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    9/17/93
  3.     AUTHOR: Eric R. Rosé
  4.     
  5.     CLASS:  CPPSpawnConfirmTask
  6.     
  7.     SUPERCLASS: CPPPeriodicTask
  8.     
  9.         This C++ class periodically spawns a ConfirmUsers Task
  10.     
  11. ********************************************************************/
  12.  
  13. #include "CPPSpawnConfirmTask.h"
  14. #include "CPPConfirmUsers.h"
  15. #include "CPPTaskManager.h"
  16.  
  17. /*-----------------------------------------------------------------*/
  18. /*------------------------ PUBLIC METHODS -------------------------*/
  19. /*-----------------------------------------------------------------*/
  20.     
  21.     CPPSpawnConfirmTask::CPPSpawnConfirmTask (CPPTaskManager *TaskManager, 
  22.                                               long minPeriod, 
  23.                                               Boolean deleteWhenDone) :
  24.                               CPPPeriodicTask (TaskManager, minPeriod,
  25.                                                deleteWhenDone)
  26.     {
  27.         this->confirmTask = NULL;
  28.     }
  29.     
  30. /*-----------------------------------------------------------------*/
  31.  
  32.     CPPSpawnConfirmTask::~CPPSpawnConfirmTask (void)
  33.     {
  34.         delete confirmTask;
  35.     }
  36.     
  37. /*-----------------------------------------------------------------*/
  38.  
  39.     char *CPPSpawnConfirmTask::ClassName (void)
  40.     {
  41.         return "CPPSpawnConfirmTask";
  42.     }
  43.  
  44. /*-----------------------------------------------------------------*/
  45.  
  46.     void CPPSpawnConfirmTask::DoPeriodicAction (void)
  47.     {
  48.         // call the inherited method to update frequency count
  49.         CPPPeriodicTask::DoPeriodicAction();
  50.  
  51.         if (confirmTask->hasCompleted)
  52.           confirmTask->StartConfirmUsers (NULL);
  53.     }
  54.  
  55. /*-----------------------------------------------------------------*/
  56.  
  57.     void CPPSpawnConfirmTask::DoCompletedAction (void)
  58.     {
  59.         CPPPeriodicTask::DoCompletedAction();
  60.     }
  61.         
  62. /*-----------------------------------------------------------------*/
  63.  
  64.     void CPPSpawnConfirmTask::StartSpawnConfirmTask 
  65.                                  (CompletionProc DoProc)
  66.     {
  67.         if (!this->hasCompleted)
  68.           return;
  69.         
  70.         if (!confirmTask)
  71.           confirmTask = new CPPConfirmUsers (this->ourManager, 
  72.                                                60, FALSE);
  73.           
  74.         // note that we haven't completed yet
  75.         SetCompletionProc(DoProc);
  76.         this->hasCompleted = FALSE;
  77.         
  78.         // add ourselves to the periodic task queue
  79.         this->ourManager->AddPeriodicTask(this);
  80.     }
  81.  
  82. /*-----------------------------------------------------------------*/
  83.